package com.hmall.search.mq;




import com.hmall.search.service.SearchService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;



import static com.hmall.search.constants.ItemMqConstants.DELETE_QUEUE_NAME;
import static com.hmall.search.constants.ItemMqConstants.INSERT_QUEUE_NAME;

@Component
public class ItemListener {
    @Autowired
    private SearchService service;



    /**
     * 监听商品新增或修改的业务
     * @param id 酒店id
     */
    @RabbitListener(queues = INSERT_QUEUE_NAME)
    public void listenHotelInsertOrUpdate(Long id){
        service.saveById(id);
    }

    /**
     * 监听酒店删除的业务
     * @param id 酒店id
     */
    @RabbitListener(queues = DELETE_QUEUE_NAME)
    public void listenHotelDelete(Long id){
        service.deleteById(id);
    }
}
